home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / FITPLOT.LI < prev    next >
Text File  |  1994-08-10  |  781b  |  27 lines

  1. #  library fitplot
  2. #  fitplot(model,x, [x1,x2,...],[y1,y2,...]) 
  3. #  fits and plots data ([x1,x2,...], [y1,y2,...] ) into a model
  4. #  e.g.    fitplot(x^2,x, [1,2,3,4], [1,4,9,16])
  5.  
  6. fitplot(model_,x_,xdata_, ydata_) := block(numeric:=on,
  7.     graph,
  8.     xmax:=max(xdata)*1.05,
  9.     xmin:=min(xdata)*0.9,
  10.     ymax:=max(ydata)*1.05,
  11.     ymin:=min(ydata)*0.9,
  12.     dx:=(xmax-xmin)/getmaxx,
  13.     dy:=(ymax-ymin)/getmaxy,
  14.     length:=length(ydata),
  15.     axis(xmin,xmax,ymin,ymax),
  16.     do( circle((member(xdata,j)-xmin)/dx,getmaxy-(member(ydata,j)-ymin)/dy,2),
  17.     j,1,length,1),
  18.     xstep:=dx*10,
  19.     setcolor(colorno(yellow)),
  20.     moveto(0,getmaxy-(subs(model,x=xmin)-ymin)/dy),
  21.     do( lineto((x-xmin)/dx,getmaxy-(model-ymin)/dy),
  22.     x,xmin,xmax,xstep),
  23.     numeric:=off,
  24.     readchar,
  25.     text,
  26.     local(dx,dy,length,xstep))
  27.